<html>
<head>
    <title>订单详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <!-- jquery -->
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css"
          href="/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript" src="/bootstrap/js/bootstrap.min.js">
    </script>
    <!-- layer -->
    <script type="text/javascript" src="/layer/layer.js"></script>
    <!-- common.js -->
    <script type="text/javascript" src="/js/common.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: "Open Sans", sans-serif;
            text-transform: uppercase;
            letter-spacing: 3px;
            font-size: 11px;
        }

        body {
            background: #cbc0d3;
        }

        .main-header {
            width: 100%;
            height: 100px;
            background: #eac7cc;
            display: block;
        }

        .navbar {
            display: inline-block;
            float: right;
            margin-right: 50px;
            margin-top: 30px;
        }

        .logo {
            display: inline-block;
            margin-top: 30px;
            margin-left: 30px;
            text-decoration: none;
        }

        .logo-lg {
            font-size: 20px;
            font-weight: lighter;
            color: #232324;
        }

        .logo-lg > b {
            font-size: 20px;
            font-weight: lighter;
            color: #232324;
        }

        .container {
            background: #FFFFFF;
            padding-right: 15px;
            padding-left: 15px;
            margin-right: auto;
            margin-left: auto;
            width: 750px;
        }

    </style>
</head>

<body>

<header id="site-header" class="main-header">
    <!-- Logo -->
    <a class="logo" onclick="toList()">
        <span class="logo-lg"><b>商品抢购</b>系统</span>
    </a>

    <nav class="navbar navbar-static-top">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </a>

        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">

                <li class="dropdown user user-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <img class="user-image" alt="User Image">
                        <span class="hidden-xs"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header">
                            <img class="img-circle" alt="User Image">
                            <p>
                                Team B06 - Web Developer
                                <small>2021.4.20</small>
                            </p>
                        </li>
                        <!-- Menu Body -->
                        <li class="user-body">
                        </li>
                        <li class="user-footer">
                            <div class="pull-middle">
                                <a onclick="toList()" class="btn btn-lg btn-default btn-block">退出系统</a>
                            </div>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</header>

<div class="panel panel-default">
    <div class="panel-heading">秒杀订单详情</div>

    <div class="container">

        <table class="table" id="order">
            <tr>
                <td>商品名称</td>
                <td id="goodsName" colspan="3"></td>
            </tr>
            <tr>
                <td>商品图片</td>
                <td colspan="2"><img id="goodsImg" width="200"
                                     height="200"/></td>
            </tr>
            <tr>
                <td>订单价格</td>
                <td colspan="2" id="goodsPrice"></td>
            </tr>
            <tr>
                <td>下单时间</td>
                <td id="createDate" colspan="2"></td>
            </tr>
            <tr>
                <td>订单状态</td>
                <td id="status">

                </td>
                <td>
                    <button class="btn btn-primary btn-block" type="submit"
                            id="payButton">立即支付
                    </button>
                </td>
            </tr>
            <tr>
                <td>收货人</td>
                <td colspan="2">XXX 123123123</td>
            </tr>
            <tr>
                <td>收货地址</td>
                <td colspan="2">上海市浦东区世纪大道</td>
            </tr>
        </table>
    </div>
</div>

<script>

    function toList() {
        window.location.href = "/goods/toList";
    }

    $(function () {
        getOrderDetail();
    });

    function getOrderDetail() {
        var orderId = g_getQueryString("orderId");
        $.ajax({
            url: '/order/orderDetail',
            type: 'GET',
            data: {
                orderId: orderId
            },
            success: function (data) {
                if (data.code == 200) {
                    render(data.object);
                } else {
                    layer.msg(data.message);
                }
            },
            error: function () {
                layer.msg("客户端请求错误");
            }
        });
    }

    function render(detail) {
        var goods = detail.goodsVo;
        var order = detail.order;

        $("#goodsName").text(goods.goodsName);
        $("#goodsImg").attr("src", goods.goodsImg);
        $("#goodsPrice").text(order.goodsPrice);
        $("#createDate").text(new Date(order.createDate).format("yyyy-MM-dd HH:mm:ss"));
        var status = order.status;
        var statusText = "";
        switch (status) {
            case 0 :
                statusText = "未支付";
                break;
            case 1 :
                statusText = "待发货";
                break;
            case 2 :
                statusText = "已发货";
                break;
            case 3 :
                statusText = "已收货";
                break;
            case 4 :
                statusText = "已退款";
                break;
            case 5 :
                statusText = "已完成";
                break;
        }
        $("#status").text(statusText);
    }
</script>
</body>
</html>
